<?php
/* @var $this PartnerInvoiceController */
/* @var $model PartnerInvoice */

$this->breadcrumbs=array(
	Yii::t('PartnerInvoice','Partner Invoices')=>array('admin'),
	Yii::t('base','Manage'),
);
Yii::app()->clientScript->registerScript('search', "
$('#search-form form').submit(function(){
	$('#partner-invoice-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<script type="text/javascript">
//发放金额
function Issue(pid)
{
	$('#pid').val(pid);

	$.fancybox.open({
		href : '#inline1',
		type : 'inline',
		maxWidth	: 500,
		maxHeight	: 380,
		fitToView	: false,
		width		: '500',
		height		: '380',
		autoSize	: false,
		openEffect	: 'none',
		closeBtn	: true,//正式发布时请将true,改为false,不显示关闭按钮
	    closeClick	: false,
		helpers : {
			overlay : null,
		}
});
	
}

</script>
<div class="row-fluid">
	<div class="span12">
    	<div class="box gradient">
        	<div class="title">
           	<?php echo CHtml::link(Yii::t('common','Advanced Search'),'#collapseOne',array('class'=>'search-button accordion-toggle collapsed btn btn-mini zyBtn03','data-toggle'=>'collapse','data-parent'=>'#accordion2')); ?>
             <?php //echo CHtml::link(Yii::t('common','Create'), array('create'),array('class'=>'btn btn-small create',));?>              <h3> <i class="icon-sitemap"></i> <span><?php echo Yii::t('PartnerInvoice','Manage Partner Invoices') ?></span> </h3>
            </div>
            
			<div class="content"> 
			
 			<!--search start-->
 			
              <?php $this->renderPartial('_search',array(
					'model'=>$model,
				)); ?>
              
            <!--search over-->
            
            <!-- table start -->
            
<?php $this->widget('application.extensions.zgrid.ZGridView', array(
	'id'=>'partner-invoice-grid',
	'dataProvider'=>$model->search(),
	'itemsCssClass'=>'responsive table table-striped table-bordered',
	'pager'=>array('class'=>'CLinkPager','hiddenPageCssClass'=>'','firstPageCssClass'=>'first paginate_button','htmlOptions'=>array('class'=>'dataTables_paginate paging_full_numbers"'),'header'=>""),
	'pagerCssClass'=>'pagination',
	'cssFile'=>false,
	'template'=>'{items}{summary}{pager}',
	'columns'=>array(
		//array('name'=>'partner_invoice_id','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'issued_user','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'user_id','value'=>'PartnerInvoice::model()->getPartnerName($data->user_id)','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'sumamount','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'undisbursed_amount','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'issued_amount','headerHtmlOptions'=>array('style'=>'width:10%')),
		/*
		array('name'=>'create_time','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'update_time','headerHtmlOptions'=>array('style'=>'width:10%')),
		*/
		array(
			'class'=>'CButtonColumn',
			'header' => Yii::t ( 'common', 'Operater' ),
			'template'=>'{Issue}{delete}',
			'headerHtmlOptions'=>array('style'=>'width:10%'),
	    	'buttons'=>array (
		        'update'=> array(
		            'label'=>'<i class="gicon-edit"></i>',
		            'imageUrl'=>0,
		            'options'=>array( 'class'=>'btn btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','Update')),
		        ),
		        'view'=>array(
		            'label'=>'<i class="gicon-eye-open"></i>',
		            'imageUrl'=>0,
		            'options'=>array('class'=>'btn btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','View')),
		        ),
		        'delete'=>array(
		            'label'=>'<i class="gicon-remove icon-white"></i>',
		            'imageUrl'=>0,
		             'options'=>array( 'class'=>'btn btn-inverse btn-small','rel'=>'tooltip','data-placement'=>'left','title'=>Yii::t('common','Delete')),
		        ),
               'Issue'=>array(
                 'label'=>Yii::t('base','Issue'),
                 'url'=>'"javascript:Issue(\"".$data->partner_invoice_id."\");"',
                 'options'=>array(
                 'class' => 'btn btn-small'
                 ),
),
		     ),
	    ),
	),
)); ?>
					<!--table over -->
			</div><!--//content-->
		</div><!--//box-->
	</div><!--//span12-->
</div><!--//row-fluid-->
 <div id="inline1" font:16px/45px '微软雅黑', Arial, Helvetica, sans-serif; color:#333; background:#fff;" style="display: none;"> 
  <h1 style="font:24px/40px '微软雅黑', Arial, Helvetica, sans-serif; background:rgb(23, 177, 249) ; margin:0; color:#fff; padding:10px 30px;">发放</h1>
  <form method="post" id="form" style=" padding:20px 80px 0;">
	<p><span>发放金额:</span>
	<input type="hidden" value="" id="pid" />
    <input type="text" value="" id="amount" />
	    <p style="align:center">
        <input type="button" id="send" value="发放" style="font-size:20px !important; width:100%;"/>
      </p>
</form>
</div>
<?php 

Yii :: app()->clientScript->registerScript('search', "
			$('#send').click(function()
		{
			var amount=$('#amount').val();
            var pid=$('#pid').val();
	   		$.ajax({
					type: 'POST',
					url:'".Yii::app()->createUrl("/partnerInvoice/getIssue/")."',
					data: {'pid': pid,'amount':amount},
                    success:function(){
                        $.fancybox.close();
                        location.href ='".Yii::app()->createUrl("/partnerInvoice/admin/")."';
                    }
			});
			});
		");

?>
